Registry Mirror
Skip to content

Conversation

@bhushan4work

Copy link
Copy Markdown
Collaborator

normalize extracted page titles by decoding html entities, collapsing consecutive ascii whitespace into a single space, and trimming both ends. this prevents titles with multiline indentation or internal tabs from being stored with irregular spacing. non-ascii whitespace and meta content values are left untouched.

closes #393

how i tested this

  • added a regression test in meta-fetcher.test.ts that fails before the fix and passes after.
  • ran npm run check (0 errors, 0 warnings).
  • ran npm run test (107 test files, 2054 tests passed).
  • ran npm run build (clean server and static asset build).
  • rebased onto latest origin/dev with zero merge conflicts and a clean working tree.
  • pushed to origin/393 and verified remote commit sha bc04400.

ai assistance

none

type of change

  • bug fix
  • new template
  • new feature
  • documentation
  • tests
  • refactoring
  • performance improvement
  • other (describe below)

screenshots

not applicable (no visual changes)

checklist

  • this pr targets dev
  • i was assigned the linked issue
  • npm run check passes
  • npm run test passes
  • for a bug fix: the new test fails without my change
  • tested locally with npm run dev
  • screenshots included for visual changes
  • new templates follow the template guidelines

@bhushan4work

Copy link
Copy Markdown
Collaborator Author

@anurag629 ci is green , pr is ready for a human review . lemme know if any followup fix is to be made

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bhushan4work, nice work, the collapse handles the title from #393, meta content values are left alone, and collapsing after decodeEntities means a 
 inside a title collapses too, the way the browser does it. I ran your test's title through dev's parseMetaTags and it keeps the tabs, the double spaces and the line break, so the test catches the bug.

One thing before I can merge: the .trim() at src/lib/meta-fetcher.ts:55 now runs after decodeEntities, and JS's trim() strips U+00A0 as well, so <title>&nbsp;Hello world&nbsp;</title> loses both of them. Dev keeps them, and document.title only strips ASCII whitespace, which is what #393 means by &nbsp; staying. After the collapse the ends can only be a single space, so .replace(/^ | $/g, '') in place of .trim() does it, and please add an &nbsp; at the start or end of the title in your test so it covers this.

Everything else looks good.

@anurag629 anurag629 added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 9, 2026
@anurag629
anurag629 merged commit 44bb59d into codercops:dev Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview checker: a <title> written over several lines keeps its line break and indentation

2 participants